import time
import os

OUT = "out.csv"
TIME = "60*60*3"

def Do(cmd):
    print("Python----> "+cmd)
    os.system(str(cmd))

def Nohup(cmd):
    print("Nohup-----> "+cmd)
    os.system('nohup '+str(cmd)+' &')

Do('rm nohup.out')

Do('rm zhipin.html')

Do('rm ' + OUT)

Do('rm selenium.html')

print("是否后台运行（Y/N）")
choose = input("请选择（默认后台运行）：")
if choose == 'N' or choose == 'n':
    print("将在" + TIME + "s后启动爬虫")
    print("正在启动Scrapy爬虫······")
    time.sleep(eval(TIME))
    Do('scrapy crawl zhipin.com -o ' + OUT)
else:
    print("将在" + TIME + "s后启动爬虫")
    print("后台启动Scrapy爬虫······")
    time.sleep(eval(TIME))
    Nohup('scrapy crawl zhipin.com -o ' + OUT)
